package cn.yunhe.video.dao;

import cn.yunhe.video.entity.Collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface ICollectMapper extends BaseMapper<Collect> {

    @Select("select * from tb_collect where uid = #{uid}")
    Collect getCollectByName(int uid);

    @Insert("insert into tb_collect(id,uid) values(#{video.id},#{userInfo.uid})")
    void addCollect(Collect collect);

    @Delete("delete from tb_collect where uid=#{userInfo.uid}")
    void delCollect(Collect collect);

    @Update("update tb_video set saveNum=saveNum-1 where id = #{video.id}")
    void updateCollectDown(Collect collect);

    @Update("update tb_video set saveNum=saveNum+1 where id = #{video.id}")
    void updateCollectUp(Collect collect);
}
